package cauca.scsn.modelo.entidad;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import cauca.scsn.modelo.entidad.id.VehiculoEmpleadoId;

/**
 * VehiculoEmpleado entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "vehiculo_empleado", schema = "public")
public class VehiculoEmpleado extends EntidadGenerica {

	// Fields

	private VehiculoEmpleadoId id;
	private Vehiculo vehiculo;
	private Empleado empleado;
	private String conductorPrincipal;
	private Set<AsignacionConductor> asignacionConductors = new HashSet<AsignacionConductor>(
			0);

	// Constructors

	/** default constructor */
	public VehiculoEmpleado() {
	}

	/** minimal constructor */
	public VehiculoEmpleado(VehiculoEmpleadoId id, Vehiculo vehiculo,
			Empleado empleado, String conductorPrincipal, String status) {
		this.id = id;
		this.vehiculo = vehiculo;
		this.empleado = empleado;
		this.conductorPrincipal = conductorPrincipal;
		this.status = status;
	}

	/** full constructor */
	public VehiculoEmpleado(VehiculoEmpleadoId id, Vehiculo vehiculo,
			Empleado empleado, String conductorPrincipal, String status,
			Set<AsignacionConductor> asignacionConductors) {
		this.id = id;
		this.vehiculo = vehiculo;
		this.empleado = empleado;
		this.conductorPrincipal = conductorPrincipal;
		this.status = status;
		this.asignacionConductors = asignacionConductors;
	}

	// Property accessors
	@EmbeddedId
	@AttributeOverrides({
			@AttributeOverride(name = "idVehiculo", column = @Column(name = "id_vehiculo", nullable = false)),
			@AttributeOverride(name = "cedulaEmpleado", column = @Column(name = "cedula_empleado", nullable = false, length = 10)) })
	public VehiculoEmpleadoId getId() {
		return this.id;
	}

	public void setId(VehiculoEmpleadoId id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "id_vehiculo", nullable = false, insertable = false, updatable = false)
	public Vehiculo getVehiculo() {
		return this.vehiculo;
	}

	public void setVehiculo(Vehiculo vehiculo) {
		this.vehiculo = vehiculo;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "cedula_empleado", nullable = false, insertable = false, updatable = false)
	public Empleado getEmpleado() {
		return this.empleado;
	}

	public void setEmpleado(Empleado empleado) {
		this.empleado = empleado;
	}

	@Column(name = "conductor_principal", nullable = false, length = 1)
	public String getConductorPrincipal() {
		return this.conductorPrincipal;
	}

	public void setConductorPrincipal(String conductorPrincipal) {
		this.conductorPrincipal = conductorPrincipal;
	}

	@Column(name = "status", nullable = false, length = 1)
	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "vehiculoEmpleado")
	public Set<AsignacionConductor> getAsignacionConductors() {
		return this.asignacionConductors;
	}

	public void setAsignacionConductors(
			Set<AsignacionConductor> asignacionConductors) {
		this.asignacionConductors = asignacionConductors;
	}

	@Override
	public Object getPrimaryKey() {
		return this.id;
	}

	@Override
	public String toString() {
		return null;
	}

}